﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Genesis.Application.Commands
{
    [Genesis.Common.Attributes.CommandCode("Genesis.Application.Commands.ShowMessage")]
    [Genesis.Common.Attributes.CommandDescription("This command shows a message box")]
    [Genesis.Common.Attributes.CommandName("Message Box")]
    public class ShowMessage : Genesis.Common.Classes.CommandBase, Genesis.Common.Interfaces.ICommand
    {
        #region ICommand Members

        void Genesis.Common.Interfaces.ICommand.Execute()
        {
            string _text = string.Empty;
            string _caption = string.Empty;

            for (int i = 0; i < this.parameters.Count; i++)
            {
                if (this.parameters[i].Name == "Text")
                {
                    _text = System.Convert.ToString(this.parameters[i].Value);
                }
                else if (this.parameters[i].Name == "Caption")
                {
                    _caption = System.Convert.ToString(this.parameters[i].Value);
                }
            }

            if (_text != string.Empty)
            {
                if (_caption != string.Empty)
                {
                    System.Windows.Forms.MessageBox.Show(_text, _caption);
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show(_text);
                }
            }
        }

        #endregion
    }
}
